package com.navinfo.platform.trip.analysis.util;

import com.navinfo.platform.trip.common.arithmetic.Mileage;
import com.navinfo.platform.trip.common.arithmetic.data.InterRangeData;
import com.navinfo.platform.trip.common.arithmetic.data.OuterStatisticData;

import java.math.BigDecimal;
import java.util.Map;
import java.util.Optional;

/**
 * 修正行程统计变量的里程油耗时长数据
 * @author web
 */
public class TripStatisticFixUtils {

    /**
     * 计算行程各项统计指标的精准值<br/>
     * 通过精准后的里程油耗时长和积分里程油耗时长，精准各项统计指标
     */
    public static void fixTrips(OuterStatisticData statisticData) {
        //行程的积分里程、油耗、时长
        int totalMileage0 = statisticData.getRouteIntegralMileage();
        int totalFuel0 = statisticData.getRouteIntegralFuel();
        int totalDuration0 = statisticData.getRouteIntegralDuration();

        //行程的精准里程、油耗、时长
        int totalMileage = statisticData.getTripMileage();
        int totalFuel = statisticData.getTripFuel();
        int totalDuration = statisticData.getTripDuration();


        //精准后的数组
        Integer[] intArray;

        //在挡滑行
        statisticData.setInGearCoastMileage(fixSingleData(totalMileage0, totalMileage, statisticData.getInGearCoastMileage()));
        statisticData.setInGearCoastDuration(fixSingleData(totalDuration0, totalDuration, statisticData.getInGearCoastDuration()));

        //空挡滑行
        statisticData.setNeutralGearCoastMileage(fixSingleData(totalMileage0,totalMileage, statisticData.getNeutralGearCoastMileage()));
        statisticData.setNeutralGearCoastFuel(fixSingleData(totalFuel0,totalFuel, statisticData.getNeutralGearCoastFuel()));
        statisticData.setNeutralGearCoastDuration(fixSingleData(totalDuration0,totalDuration, statisticData.getNeutralGearCoastDuration()));

        //制动
        statisticData.setBrakeMileage(fixSingleData(totalMileage0,totalMileage, statisticData.getBrakeMileage()));
        statisticData.setBrakeDuration(fixSingleData(totalDuration0,totalDuration, statisticData.getBrakeDuration()));

        //怠速
        statisticData.setIdleFuel(fixSingleData(totalFuel0,totalFuel, statisticData.getIdleFuel()));
        statisticData.setIdleDuration(fixSingleData(totalDuration0,totalDuration, statisticData.getIdleDuration()));

        //停车通电时长 单位:S
        statisticData.setParkingPowerOnDuration(fixSingleData(totalDuration0,totalDuration, statisticData.getParkingPowerOnDuration()));

        //经济行驶
        statisticData.setEcoDrivingMileage(fixSingleData(totalMileage0,totalMileage, statisticData.getEcoDrivingMileage()));
        statisticData.setEcoDrivingFuel(fixSingleData(totalFuel0,totalFuel, statisticData.getEcoDrivingFuel()));
        statisticData.setEcoDrivingDuration(fixSingleData(totalDuration0,totalDuration, statisticData.getEcoDrivingDuration()));

        //定速巡航
        statisticData.setCruiseMileage(fixSingleData(totalMileage0,totalMileage, statisticData.getCruiseMileage()));
        statisticData.setCruiseFuel(fixSingleData(totalFuel0,totalFuel, statisticData.getCruiseFuel()));
        statisticData.setCruiseDuration(fixSingleData(totalDuration0,totalDuration, statisticData.getCruiseDuration()));

        //激烈减速
        statisticData.setSharpDownSpeedMileage(fixSingleData(totalMileage0,totalMileage, statisticData.getSharpDownSpeedMileage()));
        statisticData.setSharpDownSpeedDuration(fixSingleData(totalDuration0,totalDuration, statisticData.getSharpDownSpeedDuration()));

        //激烈加速
        statisticData.setSharpUpSpeedMileage(fixSingleData(totalMileage0,totalMileage, statisticData.getSharpUpSpeedMileage()));
        statisticData.setSharpUpSpeedFuel(fixSingleData(totalFuel0,totalFuel, statisticData.getSharpUpSpeedFuel()));
        statisticData.setSharpUpSpeedDuration(fixSingleData(totalDuration0,totalDuration, statisticData.getSharpUpSpeedDuration()));

        //急踩油门
        statisticData.setSharpStepOnGasMileage(fixSingleData(totalMileage0,totalMileage, statisticData.getSharpStepOnGasMileage()));
        statisticData.setSharpStepOnGasFuel(fixSingleData(totalFuel0,totalFuel, statisticData.getSharpStepOnGasFuel()));
        statisticData.setSharpStepOnGasDuration(fixSingleData(totalDuration0,totalDuration, statisticData.getSharpStepOnGasDuration()));

        //车辆起步
        statisticData.setVehicleStartMileage(fixSingleData(totalMileage0,totalMileage, statisticData.getVehicleStartMileage()));
        statisticData.setVehicleStartFuel(fixSingleData(totalFuel0,totalFuel, statisticData.getVehicleStartFuel()));
        statisticData.setVehicleStartDuration(fixSingleData(totalDuration0,totalDuration, statisticData.getVehicleStartDuration()));

        //冷车起步
        statisticData.setVehicleColdStartMileage(fixSingleData(totalMileage0,totalMileage, statisticData.getVehicleColdStartMileage()));
        statisticData.setVehicleColdStartFuel(fixSingleData(totalFuel0,totalFuel, statisticData.getVehicleColdStartFuel()));
        statisticData.setVehicleColdStartDuration(fixSingleData(totalDuration0,totalDuration, statisticData.getVehicleColdStartDuration()));


        //加油数量 单位:ML
        statisticData.setChargeFuel(fixSingleData(totalFuel0, totalFuel, statisticData.getChargeFuel()));

        //漏油数量 单位:ML
        statisticData.setLeakFuel(fixSingleData(totalFuel0,totalFuel, statisticData.getLeakFuel()));

        //油门稳定性时长 单位:S
        statisticData.setGasStabilityDuration(fixSingleData(totalDuration0,totalDuration, statisticData.getGasStabilityDuration()));

        //辅助制动
        statisticData.setAssistBrakeMileage(fixSingleData(totalMileage0,totalMileage, statisticData.getAssistBrakeMileage()));
        statisticData.setAssistBrakeDuration(fixSingleData(totalDuration0,totalDuration, statisticData.getAssistBrakeDuration()));

        //停车轰油门
        statisticData.setParkThrottleFuel(fixSingleData(totalFuel0,totalFuel, statisticData.getParkThrottleFuel()));
        statisticData.setParkThrottleDuration(fixSingleData(totalDuration0,totalDuration, statisticData.getParkThrottleDuration()));

        //行驶过程中手刹使用
        statisticData.setDrivingHandbrakeMileage(fixSingleData(totalMileage0,totalMileage, statisticData.getDrivingHandbrakeMileage()));
        statisticData.setDrivingHandbrakeDuration(fixSingleData(totalDuration0,totalDuration, statisticData.getDrivingHandbrakeDuration()));

        //怠速状态下手刹使用时长 单位:S
        statisticData.setIdleHandbrakeDuration(fixSingleData(totalDuration0,totalDuration, statisticData.getIdleHandbrakeDuration()));

        //城市非城市里程 单位M
        intArray = fixArrayData(totalMileage, new Integer[]{statisticData.getCityDrivingMileage(), statisticData.getRuralDrivingMileage()});
        statisticData.setCityDrivingMileage(intArray[0]);
        statisticData.setRuralDrivingMileage(intArray[1]);
        //城市非城市油耗  单位:ML
        intArray = fixArrayData(totalFuel, new Integer[]{statisticData.getCityDrivingFuel(),statisticData.getRuralDrivingFuel()});
        statisticData.setCityDrivingFuel(intArray[0]);
        statisticData.setRuralDrivingFuel(intArray[1]);
        //城市非城市时长 单位:S
        intArray = fixArrayData(totalDuration, new Integer[]{statisticData.getCityDrivingDuration(),statisticData.getRuralDrivingDuration()});
        statisticData.setCityDrivingDuration(intArray[0]);
        statisticData.setRuralDrivingDuration(intArray[1]);

        //上坡下坡平路里程 单位:M
        intArray = fixArrayData(totalMileage, new Integer[]{statisticData.getUpSlopeDrivingMileage(), statisticData.getDownSlopeDrivingMileage(),statisticData.getLevelRoadDrivingMileage()});
        statisticData.setUpSlopeDrivingMileage(intArray[0]);
        statisticData.setDownSlopeDrivingMileage(intArray[1]);
        statisticData.setLevelRoadDrivingMileage(intArray[2]);
        //上坡下坡平路油耗 单位:ML
        intArray = fixArrayData(totalFuel, new Integer[]{ statisticData.getUpSlopeDrivingFuel(),statisticData.getDownSlopeDrivingFuel(), statisticData.getLevelRoadDrivingFuel()});
        statisticData.setUpSlopeDrivingFuel(intArray[0]);
        statisticData.setDownSlopeDrivingFuel(intArray[1]);
        statisticData.setLevelRoadDrivingFuel(intArray[2]);
        //上坡下坡平路时长 单位:S
        intArray = fixArrayData(totalDuration, new Integer[]{ statisticData.getUpSlopeDrivingDuration(), statisticData.getDownSlopeDrivingDuration(),statisticData.getLevelRoadDrivingDuration()});
        statisticData.setUpSlopeDrivingDuration(intArray[0]);
        statisticData.setDownSlopeDrivingDuration(intArray[1]);
        statisticData.setLevelRoadDrivingDuration(intArray[2]);

        //水温区间时长
        intArray = fixArrayData(totalDuration, new Integer[]{
                statisticData.getWorkWaterTemp50Duration(),
                statisticData.getWorkWaterTemp70Duration(),
                statisticData.getWorkWaterTemp80Duration(),
                statisticData.getWorkWaterTemp85Duration(),
                statisticData.getWorkWaterTemp90Duration(),
                statisticData.getWorkWaterTemp95Duration(),
                statisticData.getWorkWaterTemp100Duration(),
                statisticData.getWorkWaterTemp105Duration(),
                statisticData.getWorkWaterTemp110Duration(),
                statisticData.getWorkWaterTemp115Duration(),
                statisticData.getWorkWaterTemp120Duration(),
                statisticData.getWorkWaterTemp125Duration(),
                statisticData.getWorkWaterTemp130Duration(),
                statisticData.getWorkWaterTemp135Duration(),
                statisticData.getWorkWaterTemp140Duration(),
                statisticData.getWorkWaterTemp145Duration(),
                statisticData.getWorkWaterTemp150Duration(),
                statisticData.getWorkWaterTempOver150Duration(),
                statisticData.getIdleWaterTemp50Duration(),
                statisticData.getIdleWaterTemp70Duration(),
                statisticData.getIdleWaterTemp80Duration(),
                statisticData.getIdleWaterTemp85Duration(),
                statisticData.getIdleWaterTemp90Duration(),
                statisticData.getIdleWaterTemp95Duration(),
                statisticData.getIdleWaterTemp100Duration(),
                statisticData.getIdleWaterTemp105Duration(),
                statisticData.getIdleWaterTemp110Duration(),
                statisticData.getIdleWaterTemp115Duration(),
                statisticData.getIdleWaterTemp120Duration(),
                statisticData.getIdleWaterTemp125Duration(),
                statisticData.getIdleWaterTemp130Duration(),
                statisticData.getIdleWaterTemp135Duration(),
                statisticData.getIdleWaterTemp140Duration(),
                statisticData.getIdleWaterTemp145Duration(),
                statisticData.getIdleWaterTemp150Duration(),
                statisticData.getIdleWaterTempOver150Duration()
        });
        statisticData.setWorkWaterTemp50Duration(intArray[0]);
        statisticData.setWorkWaterTemp70Duration(intArray[1]);
        statisticData.setWorkWaterTemp80Duration(intArray[2]);
        statisticData.setWorkWaterTemp85Duration(intArray[3]);
        statisticData.setWorkWaterTemp90Duration(intArray[4]);
        statisticData.setWorkWaterTemp95Duration(intArray[5]);
        statisticData.setWorkWaterTemp100Duration(intArray[6]);
        statisticData.setWorkWaterTemp105Duration(intArray[7]);
        statisticData.setWorkWaterTemp110Duration(intArray[8]);
        statisticData.setWorkWaterTemp115Duration(intArray[9]);
        statisticData.setWorkWaterTemp120Duration(intArray[10]);
        statisticData.setWorkWaterTemp125Duration(intArray[11]);
        statisticData.setWorkWaterTemp130Duration(intArray[12]);
        statisticData.setWorkWaterTemp135Duration(intArray[13]);
        statisticData.setWorkWaterTemp140Duration(intArray[14]);
        statisticData.setWorkWaterTemp145Duration(intArray[15]);
        statisticData.setWorkWaterTemp150Duration(intArray[16]);
        statisticData.setWorkWaterTempOver150Duration(intArray[17]);
        statisticData.setIdleWaterTemp50Duration(intArray[18]);
        statisticData.setIdleWaterTemp70Duration(intArray[19]);
        statisticData.setIdleWaterTemp80Duration(intArray[20]);
        statisticData.setIdleWaterTemp85Duration(intArray[21]);
        statisticData.setIdleWaterTemp90Duration(intArray[22]);
        statisticData.setIdleWaterTemp95Duration(intArray[23]);
        statisticData.setIdleWaterTemp100Duration(intArray[24]);
        statisticData.setIdleWaterTemp105Duration(intArray[25]);
        statisticData.setIdleWaterTemp110Duration(intArray[26]);
        statisticData.setIdleWaterTemp115Duration(intArray[27]);
        statisticData.setIdleWaterTemp120Duration(intArray[28]);
        statisticData.setIdleWaterTemp125Duration(intArray[29]);
        statisticData.setIdleWaterTemp130Duration(intArray[30]);
        statisticData.setIdleWaterTemp135Duration(intArray[31]);
        statisticData.setIdleWaterTemp140Duration(intArray[32]);
        statisticData.setIdleWaterTemp145Duration(intArray[33]);
        statisticData.setIdleWaterTemp150Duration(intArray[34]);
        statisticData.setIdleWaterTempOver150Duration(intArray[35]);

        //油门开合度
        intArray = fixArrayData(totalMileage, new Integer[]{
                statisticData.getGasOpenPercent0Mileage(),
                statisticData.getGasOpenPercent10Mileage(),
                statisticData.getGasOpenPercent20Mileage(),
                statisticData.getGasOpenPercent30Mileage(),
                statisticData.getGasOpenPercent40Mileage(),
                statisticData.getGasOpenPercent50Mileage(),
                statisticData.getGasOpenPercent60Mileage(),
                statisticData.getGasOpenPercent70Mileage(),
                statisticData.getGasOpenPercent80Mileage(),
                statisticData.getGasOpenPercent90Mileage(),
                statisticData.getGasOpenPercent99Mileage(),
                statisticData.getGasOpenPercent100Mileage()
        });
        statisticData.setGasOpenPercent0Mileage(intArray[0]);
        statisticData.setGasOpenPercent10Mileage(intArray[1]);
        statisticData.setGasOpenPercent20Mileage(intArray[2]);
        statisticData.setGasOpenPercent30Mileage(intArray[3]);
        statisticData.setGasOpenPercent40Mileage(intArray[4]);
        statisticData.setGasOpenPercent50Mileage(intArray[5]);
        statisticData.setGasOpenPercent60Mileage(intArray[6]);
        statisticData.setGasOpenPercent70Mileage(intArray[7]);
        statisticData.setGasOpenPercent80Mileage(intArray[8]);
        statisticData.setGasOpenPercent90Mileage(intArray[9]);
        statisticData.setGasOpenPercent99Mileage(intArray[10]);
        statisticData.setGasOpenPercent100Mileage(intArray[11]);
        
        intArray = fixArrayData(totalFuel, new Integer[]{
                statisticData.getGasOpenPercent0Fuel(),
                statisticData.getGasOpenPercent10Fuel(),
                statisticData.getGasOpenPercent20Fuel(),
                statisticData.getGasOpenPercent30Fuel(),
                statisticData.getGasOpenPercent40Fuel(),
                statisticData.getGasOpenPercent50Fuel(),
                statisticData.getGasOpenPercent60Fuel(),
                statisticData.getGasOpenPercent70Fuel(),
                statisticData.getGasOpenPercent80Fuel(),
                statisticData.getGasOpenPercent90Fuel(),
                statisticData.getGasOpenPercent99Fuel(),
                statisticData.getGasOpenPercent100Fuel()
        });
        statisticData.setGasOpenPercent0Fuel(intArray[0]);
        statisticData.setGasOpenPercent10Fuel(intArray[1]);
        statisticData.setGasOpenPercent20Fuel(intArray[2]);
        statisticData.setGasOpenPercent30Fuel(intArray[3]);
        statisticData.setGasOpenPercent40Fuel(intArray[4]);
        statisticData.setGasOpenPercent50Fuel(intArray[5]);
        statisticData.setGasOpenPercent60Fuel(intArray[6]);
        statisticData.setGasOpenPercent70Fuel(intArray[7]);
        statisticData.setGasOpenPercent80Fuel(intArray[8]);
        statisticData.setGasOpenPercent90Fuel(intArray[9]);
        statisticData.setGasOpenPercent99Fuel(intArray[10]);
        statisticData.setGasOpenPercent100Fuel(intArray[11]);
        
        intArray = fixArrayData(totalDuration, new Integer[]{
                statisticData.getGasOpenPercent0Duration(),
                statisticData.getGasOpenPercent10Duration(),
                statisticData.getGasOpenPercent20Duration(),
                statisticData.getGasOpenPercent30Duration(),
                statisticData.getGasOpenPercent40Duration(),
                statisticData.getGasOpenPercent50Duration(),
                statisticData.getGasOpenPercent60Duration(),
                statisticData.getGasOpenPercent70Duration(),
                statisticData.getGasOpenPercent80Duration(),
                statisticData.getGasOpenPercent90Duration(),
                statisticData.getGasOpenPercent99Duration(),
                statisticData.getGasOpenPercent100Duration()
        });
        statisticData.setGasOpenPercent0Duration(intArray[0]);
        statisticData.setGasOpenPercent10Duration(intArray[1]);
        statisticData.setGasOpenPercent20Duration(intArray[2]);
        statisticData.setGasOpenPercent30Duration(intArray[3]);
        statisticData.setGasOpenPercent40Duration(intArray[4]);
        statisticData.setGasOpenPercent50Duration(intArray[5]);
        statisticData.setGasOpenPercent60Duration(intArray[6]);
        statisticData.setGasOpenPercent70Duration(intArray[7]);
        statisticData.setGasOpenPercent80Duration(intArray[8]);
        statisticData.setGasOpenPercent90Duration(intArray[9]);
        statisticData.setGasOpenPercent99Duration(intArray[10]);
        statisticData.setGasOpenPercent100Duration(intArray[11]);
        
        //扭矩区间
        intArray = fixArrayData(totalMileage, new Integer[]{
                statisticData.getTorque0Mileage(),
                statisticData.getTorque10Mileage(),
                statisticData.getTorque20Mileage(),
                statisticData.getTorque30Mileage(),
                statisticData.getTorque40Mileage(),
                statisticData.getTorque50Mileage(),
                statisticData.getTorque60Mileage(),
                statisticData.getTorque70Mileage(),
                statisticData.getTorque80Mileage(),
                statisticData.getTorque90Mileage(),
                statisticData.getTorque99Mileage(),
                statisticData.getTorque100Mileage()
        });
        statisticData.setTorque0Mileage(intArray[0]);
        statisticData.setTorque10Mileage(intArray[1]);
        statisticData.setTorque20Mileage(intArray[2]);
        statisticData.setTorque30Mileage(intArray[3]);
        statisticData.setTorque40Mileage(intArray[4]);
        statisticData.setTorque50Mileage(intArray[5]);
        statisticData.setTorque60Mileage(intArray[6]);
        statisticData.setTorque70Mileage(intArray[7]);
        statisticData.setTorque80Mileage(intArray[8]);
        statisticData.setTorque90Mileage(intArray[9]);
        statisticData.setTorque99Mileage(intArray[10]);
        statisticData.setTorque100Mileage(intArray[11]);
        intArray = fixArrayData(totalFuel, new Integer[]{
                statisticData.getTorque0Fuel(),
                statisticData.getTorque10Fuel(),
                statisticData.getTorque20Fuel(),
                statisticData.getTorque30Fuel(),
                statisticData.getTorque40Fuel(),
                statisticData.getTorque50Fuel(),
                statisticData.getTorque60Fuel(),
                statisticData.getTorque70Fuel(),
                statisticData.getTorque80Fuel(),
                statisticData.getTorque90Fuel(),
                statisticData.getTorque99Fuel(),
                statisticData.getTorque100Fuel()
        });
        statisticData.setTorque0Fuel(intArray[0]);
        statisticData.setTorque10Fuel(intArray[1]);
        statisticData.setTorque20Fuel(intArray[2]);
        statisticData.setTorque30Fuel(intArray[3]);
        statisticData.setTorque40Fuel(intArray[4]);
        statisticData.setTorque50Fuel(intArray[5]);
        statisticData.setTorque60Fuel(intArray[6]);
        statisticData.setTorque70Fuel(intArray[7]);
        statisticData.setTorque80Fuel(intArray[8]);
        statisticData.setTorque90Fuel(intArray[9]);
        statisticData.setTorque99Fuel(intArray[10]);
        statisticData.setTorque100Fuel(intArray[11]);
        intArray = fixArrayData(totalDuration, new Integer[]{
                statisticData.getTorque0Duration(),
                statisticData.getTorque10Duration(),
                statisticData.getTorque20Duration(),
                statisticData.getTorque30Duration(),
                statisticData.getTorque40Duration(),
                statisticData.getTorque50Duration(),
                statisticData.getTorque60Duration(),
                statisticData.getTorque70Duration(),
                statisticData.getTorque80Duration(),
                statisticData.getTorque90Duration(),
                statisticData.getTorque99Duration(),
                statisticData.getTorque100Duration()
        });
        statisticData.setTorque0Duration(intArray[0]);
        statisticData.setTorque10Duration(intArray[1]);
        statisticData.setTorque20Duration(intArray[2]);
        statisticData.setTorque30Duration(intArray[3]);
        statisticData.setTorque40Duration(intArray[4]);
        statisticData.setTorque50Duration(intArray[5]);
        statisticData.setTorque60Duration(intArray[6]);
        statisticData.setTorque70Duration(intArray[7]);
        statisticData.setTorque80Duration(intArray[8]);
        statisticData.setTorque90Duration(intArray[9]);
        statisticData.setTorque99Duration(intArray[10]);
        statisticData.setTorque100Duration(intArray[11]);
        
        //进气温度区间时长
        intArray = fixArrayData(totalDuration, new Integer[]{
                statisticData.getIat50Duration(),
                statisticData.getIat70Duration(),
                statisticData.getIat80Duration(),
                statisticData.getIat85Duration(),
                statisticData.getIat90Duration(),
                statisticData.getIat95Duration(),
                statisticData.getIat100Duration(),
                statisticData.getIat105Duration(),
                statisticData.getIat110Duration(),
                statisticData.getIat115Duration(),
                statisticData.getIat120Duration(),
                statisticData.getIat125Duration(),
                statisticData.getIat130Duration(),
                statisticData.getIat135Duration(),
                statisticData.getIat140Duration(),
                statisticData.getIat145Duration(),
                statisticData.getIat150Duration(),
                statisticData.getIatOver150Duration()
        });
        statisticData.setIat50Duration(intArray[0]);
        statisticData.setIat70Duration(intArray[1]);
        statisticData.setIat80Duration(intArray[2]);
        statisticData.setIat85Duration(intArray[3]);
        statisticData.setIat90Duration(intArray[4]);
        statisticData.setIat95Duration(intArray[5]);
        statisticData.setIat100Duration(intArray[6]);
        statisticData.setIat105Duration(intArray[7]);
        statisticData.setIat110Duration(intArray[8]);
        statisticData.setIat115Duration(intArray[9]);
        statisticData.setIat120Duration(intArray[10]);
        statisticData.setIat125Duration(intArray[11]);
        statisticData.setIat130Duration(intArray[12]);
        statisticData.setIat135Duration(intArray[13]);
        statisticData.setIat140Duration(intArray[14]);
        statisticData.setIat145Duration(intArray[15]);
        statisticData.setIat150Duration(intArray[16]);
        statisticData.setIatOver150Duration(intArray[17]);

        //进气压力区间时长
        intArray = fixArrayData(totalDuration, new Integer[]{
                statisticData.getIp50Duration(),
                statisticData.getIp60Duration(),
                statisticData.getIp70Duration(),
                statisticData.getIp80Duration(),
                statisticData.getIp90Duration(),
                statisticData.getIp100Duration(),
                statisticData.getIp110Duration(),
                statisticData.getIp120Duration(),
                statisticData.getIp130Duration(),
                statisticData.getIp140Duration(),
                statisticData.getIp150Duration(),
                statisticData.getIpOver150Duration()
        });
        statisticData.setIp50Duration(intArray[0]);
        statisticData.setIp60Duration(intArray[1]);
        statisticData.setIp70Duration(intArray[2]);
        statisticData.setIp80Duration(intArray[3]);
        statisticData.setIp90Duration(intArray[4]);
        statisticData.setIp100Duration(intArray[5]);
        statisticData.setIp110Duration(intArray[6]);
        statisticData.setIp120Duration(intArray[7]);
        statisticData.setIp130Duration(intArray[8]);
        statisticData.setIp140Duration(intArray[9]);
        statisticData.setIp150Duration(intArray[10]);
        statisticData.setIpOver150Duration(intArray[11]);

        //速度区间里程
        intArray = fixArrayData(totalMileage, new Integer[]{
                statisticData.getSpeedRange01Mileage(),
                statisticData.getSpeedRange02Mileage(),
                statisticData.getSpeedRange03Mileage(),
                statisticData.getSpeedRange04Mileage(),
                statisticData.getSpeedRange05Mileage(),
                statisticData.getSpeedRange06Mileage(),
                statisticData.getSpeedRange07Mileage(),
                statisticData.getSpeedRange08Mileage(),
                statisticData.getSpeedRange09Mileage(),
                statisticData.getSpeedRange10Mileage(),
                statisticData.getSpeedRange11Mileage(),
                statisticData.getSpeedRange12Mileage(),
                statisticData.getExceedSpeedRangeMileage()
        });
        statisticData.setSpeedRange01Mileage(intArray[0]);
        statisticData.setSpeedRange02Mileage(intArray[1]);
        statisticData.setSpeedRange03Mileage(intArray[2]);
        statisticData.setSpeedRange04Mileage(intArray[3]);
        statisticData.setSpeedRange05Mileage(intArray[4]);
        statisticData.setSpeedRange06Mileage(intArray[5]);
        statisticData.setSpeedRange07Mileage(intArray[6]);
        statisticData.setSpeedRange08Mileage(intArray[7]);
        statisticData.setSpeedRange09Mileage(intArray[8]);
        statisticData.setSpeedRange10Mileage(intArray[9]);
        statisticData.setSpeedRange11Mileage(intArray[10]);
        statisticData.setSpeedRange12Mileage(intArray[11]);
        statisticData.setExceedSpeedRangeMileage(intArray[12]);
        //速度区间油耗
        intArray = fixArrayData(totalFuel, new Integer[]{
                statisticData.getSpeedRange01Fuel(),
                statisticData.getSpeedRange02Fuel(),
                statisticData.getSpeedRange03Fuel(),
                statisticData.getSpeedRange04Fuel(),
                statisticData.getSpeedRange05Fuel(),
                statisticData.getSpeedRange06Fuel(),
                statisticData.getSpeedRange07Fuel(),
                statisticData.getSpeedRange08Fuel(),
                statisticData.getSpeedRange09Fuel(),
                statisticData.getSpeedRange10Fuel(),
                statisticData.getSpeedRange11Fuel(),
                statisticData.getSpeedRange12Fuel(),
                statisticData.getExceedSpeedRangeFuel()
        });
        statisticData.setSpeedRange01Fuel(intArray[0]);
        statisticData.setSpeedRange02Fuel(intArray[1]);
        statisticData.setSpeedRange03Fuel(intArray[2]);
        statisticData.setSpeedRange04Fuel(intArray[3]);
        statisticData.setSpeedRange05Fuel(intArray[4]);
        statisticData.setSpeedRange06Fuel(intArray[5]);
        statisticData.setSpeedRange07Fuel(intArray[6]);
        statisticData.setSpeedRange08Fuel(intArray[7]);
        statisticData.setSpeedRange09Fuel(intArray[8]);
        statisticData.setSpeedRange10Fuel(intArray[9]);
        statisticData.setSpeedRange11Fuel(intArray[10]);
        statisticData.setSpeedRange12Fuel(intArray[11]);
        statisticData.setExceedSpeedRangeFuel(intArray[12]);
        //速度区间时长
        intArray = fixArrayData(totalDuration, new Integer[]{
                statisticData.getSpeedRange01Duration(),
                statisticData.getSpeedRange02Duration(),
                statisticData.getSpeedRange03Duration(),
                statisticData.getSpeedRange04Duration(),
                statisticData.getSpeedRange05Duration(),
                statisticData.getSpeedRange06Duration(),
                statisticData.getSpeedRange07Duration(),
                statisticData.getSpeedRange08Duration(),
                statisticData.getSpeedRange09Duration(),
                statisticData.getSpeedRange10Duration(),
                statisticData.getSpeedRange11Duration(),
                statisticData.getSpeedRange12Duration(),
                statisticData.getExceedSpeedRangeDuration()
        });
        statisticData.setSpeedRange01Duration(intArray[0]);
        statisticData.setSpeedRange02Duration(intArray[1]);
        statisticData.setSpeedRange03Duration(intArray[2]);
        statisticData.setSpeedRange04Duration(intArray[3]);
        statisticData.setSpeedRange05Duration(intArray[4]);
        statisticData.setSpeedRange06Duration(intArray[5]);
        statisticData.setSpeedRange07Duration(intArray[6]);
        statisticData.setSpeedRange08Duration(intArray[7]);
        statisticData.setSpeedRange09Duration(intArray[8]);
        statisticData.setSpeedRange10Duration(intArray[9]);
        statisticData.setSpeedRange11Duration(intArray[10]);
        statisticData.setSpeedRange12Duration(intArray[11]);
        statisticData.setExceedSpeedRangeDuration(intArray[12]);

        //档位里程
        intArray = fixArrayData(totalMileage, new Integer[]{
                statisticData.getGear01Mileage(),
                statisticData.getGear02Mileage(),
                statisticData.getGear03Mileage(),
                statisticData.getGear04Mileage(),
                statisticData.getGear05Mileage(),
                statisticData.getGear06Mileage(),
                statisticData.getGear07Mileage(),
                statisticData.getGear08Mileage(),
                statisticData.getGear09Mileage(),
                statisticData.getGear10Mileage(),
                statisticData.getGear11Mileage(),
                statisticData.getGear12Mileage(),
                statisticData.getGear13Mileage(),
                statisticData.getGear14Mileage(),
                statisticData.getGear15Mileage(),
                statisticData.getGear16Mileage(),
                statisticData.getGearOtherMileage()
        });
        statisticData.setGear01Mileage(intArray[0]);
        statisticData.setGear02Mileage(intArray[1]);
        statisticData.setGear03Mileage(intArray[2]);
        statisticData.setGear04Mileage(intArray[3]);
        statisticData.setGear05Mileage(intArray[4]);
        statisticData.setGear06Mileage(intArray[5]);
        statisticData.setGear07Mileage(intArray[6]);
        statisticData.setGear08Mileage(intArray[7]);
        statisticData.setGear09Mileage(intArray[8]);
        statisticData.setGear10Mileage(intArray[9]);
        statisticData.setGear11Mileage(intArray[10]);
        statisticData.setGear12Mileage(intArray[11]);
        statisticData.setGear13Mileage(intArray[12]);
        statisticData.setGear14Mileage(intArray[13]);
        statisticData.setGear15Mileage(intArray[14]);
        statisticData.setGear16Mileage(intArray[15]);
        statisticData.setGearOtherMileage(intArray[16]);
        //档位油耗
        intArray = fixArrayData(totalFuel, new Integer[]{
                statisticData.getGear01Fuel(),
                statisticData.getGear02Fuel(),
                statisticData.getGear03Fuel(),
                statisticData.getGear04Fuel(),
                statisticData.getGear05Fuel(),
                statisticData.getGear06Fuel(),
                statisticData.getGear07Fuel(),
                statisticData.getGear08Fuel(),
                statisticData.getGear09Fuel(),
                statisticData.getGear10Fuel(),
                statisticData.getGear11Fuel(),
                statisticData.getGear12Fuel(),
                statisticData.getGear13Fuel(),
                statisticData.getGear14Fuel(),
                statisticData.getGear15Fuel(),
                statisticData.getGear16Fuel(),
                statisticData.getGearOtherFuel()
        });
        statisticData.setGear01Fuel(intArray[0]);
        statisticData.setGear02Fuel(intArray[1]);
        statisticData.setGear03Fuel(intArray[2]);
        statisticData.setGear04Fuel(intArray[3]);
        statisticData.setGear05Fuel(intArray[4]);
        statisticData.setGear06Fuel(intArray[5]);
        statisticData.setGear07Fuel(intArray[6]);
        statisticData.setGear08Fuel(intArray[7]);
        statisticData.setGear09Fuel(intArray[8]);
        statisticData.setGear10Fuel(intArray[9]);
        statisticData.setGear11Fuel(intArray[10]);
        statisticData.setGear12Fuel(intArray[11]);
        statisticData.setGear13Fuel(intArray[12]);
        statisticData.setGear14Fuel(intArray[13]);
        statisticData.setGear15Fuel(intArray[14]);
        statisticData.setGear16Fuel(intArray[15]);
        statisticData.setGearOtherFuel(intArray[16]);
        //档位时长
        intArray = fixArrayData(totalDuration, new Integer[]{
                statisticData.getGear01Duration(),
                statisticData.getGear02Duration(),
                statisticData.getGear03Duration(),
                statisticData.getGear04Duration(),
                statisticData.getGear05Duration(),
                statisticData.getGear06Duration(),
                statisticData.getGear07Duration(),
                statisticData.getGear08Duration(),
                statisticData.getGear09Duration(),
                statisticData.getGear10Duration(),
                statisticData.getGear11Duration(),
                statisticData.getGear12Duration(),
                statisticData.getGear13Duration(),
                statisticData.getGear14Duration(),
                statisticData.getGear15Duration(),
                statisticData.getGear16Duration(),
                statisticData.getGearOtherDuration()
        });
        statisticData.setGear01Duration(intArray[0]);
        statisticData.setGear02Duration(intArray[1]);
        statisticData.setGear03Duration(intArray[2]);
        statisticData.setGear04Duration(intArray[3]);
        statisticData.setGear05Duration(intArray[4]);
        statisticData.setGear06Duration(intArray[5]);
        statisticData.setGear07Duration(intArray[6]);
        statisticData.setGear08Duration(intArray[7]);
        statisticData.setGear09Duration(intArray[8]);
        statisticData.setGear10Duration(intArray[9]);
        statisticData.setGear11Duration(intArray[10]);
        statisticData.setGear12Duration(intArray[11]);
        statisticData.setGear13Duration(intArray[12]);
        statisticData.setGear14Duration(intArray[13]);
        statisticData.setGear15Duration(intArray[14]);
        statisticData.setGear16Duration(intArray[15]);
        statisticData.setGearOtherDuration(intArray[16]);

        //转速区间里程
        intArray = fixArrayData(totalMileage, new Integer[]{
                statisticData.getRpmRange500Mileage(),
                statisticData.getRpmRange600Mileage(),
                statisticData.getRpmRange700Mileage(),
                statisticData.getRpmRange800Mileage(),
                statisticData.getRpmRange900Mileage(),
                statisticData.getRpmRange1000Mileage(),
                statisticData.getRpmRange1100Mileage(),
                statisticData.getRpmRange1200Mileage(),
                statisticData.getRpmRange1300Mileage(),
                statisticData.getRpmRange1400Mileage(),
                statisticData.getRpmRange1500Mileage(),
                statisticData.getRpmRange1600Mileage(),
                statisticData.getRpmRange1700Mileage(),
                statisticData.getRpmRange1800Mileage(),
                statisticData.getRpmRange1900Mileage(),
                statisticData.getRpmRange2000Mileage(),
                statisticData.getRpmRange2100Mileage(),
                statisticData.getRpmRange2200Mileage(),
                statisticData.getRpmRange2300Mileage(),
                statisticData.getRpmRange2400Mileage(),
                statisticData.getRpmRange2500Mileage(),
                statisticData.getRpmRange2600Mileage(),
                statisticData.getRpmRange2700Mileage(),
                statisticData.getRpmRange2800Mileage(),
                statisticData.getRpmRange2900Mileage(),
                statisticData.getRpmRange3000Mileage(),
                statisticData.getRpmRangeOver3000Mileage(),
        });
        statisticData.setRpmRange500Mileage(intArray[0]);
        statisticData.setRpmRange600Mileage(intArray[1]);
        statisticData.setRpmRange700Mileage(intArray[2]);
        statisticData.setRpmRange800Mileage(intArray[3]);
        statisticData.setRpmRange900Mileage(intArray[4]);
        statisticData.setRpmRange1000Mileage(intArray[5]);
        statisticData.setRpmRange1100Mileage(intArray[6]);
        statisticData.setRpmRange1200Mileage(intArray[7]);
        statisticData.setRpmRange1300Mileage(intArray[8]);
        statisticData.setRpmRange1400Mileage(intArray[9]);
        statisticData.setRpmRange1500Mileage(intArray[10]);
        statisticData.setRpmRange1600Mileage(intArray[11]);
        statisticData.setRpmRange1700Mileage(intArray[12]);
        statisticData.setRpmRange1800Mileage(intArray[13]);
        statisticData.setRpmRange1900Mileage(intArray[14]);
        statisticData.setRpmRange2000Mileage(intArray[15]);
        statisticData.setRpmRange2100Mileage(intArray[16]);
        statisticData.setRpmRange2200Mileage(intArray[17]);
        statisticData.setRpmRange2300Mileage(intArray[18]);
        statisticData.setRpmRange2400Mileage(intArray[19]);
        statisticData.setRpmRange2500Mileage(intArray[20]);
        statisticData.setRpmRange2600Mileage(intArray[21]);
        statisticData.setRpmRange2700Mileage(intArray[22]);
        statisticData.setRpmRange2800Mileage(intArray[23]);
        statisticData.setRpmRange2900Mileage(intArray[24]);
        statisticData.setRpmRange3000Mileage(intArray[25]);
        statisticData.setRpmRangeOver3000Mileage(intArray[26]);
        //转速区间油耗
        intArray = fixArrayData(totalFuel, new Integer[]{
                statisticData.getRpmRange500Fuel(),
                statisticData.getRpmRange600Fuel(),
                statisticData.getRpmRange700Fuel(),
                statisticData.getRpmRange800Fuel(),
                statisticData.getRpmRange900Fuel(),
                statisticData.getRpmRange1000Fuel(),
                statisticData.getRpmRange1100Fuel(),
                statisticData.getRpmRange1200Fuel(),
                statisticData.getRpmRange1300Fuel(),
                statisticData.getRpmRange1400Fuel(),
                statisticData.getRpmRange1500Fuel(),
                statisticData.getRpmRange1600Fuel(),
                statisticData.getRpmRange1700Fuel(),
                statisticData.getRpmRange1800Fuel(),
                statisticData.getRpmRange1900Fuel(),
                statisticData.getRpmRange2000Fuel(),
                statisticData.getRpmRange2100Fuel(),
                statisticData.getRpmRange2200Fuel(),
                statisticData.getRpmRange2300Fuel(),
                statisticData.getRpmRange2400Fuel(),
                statisticData.getRpmRange2500Fuel(),
                statisticData.getRpmRange2600Fuel(),
                statisticData.getRpmRange2700Fuel(),
                statisticData.getRpmRange2800Fuel(),
                statisticData.getRpmRange2900Fuel(),
                statisticData.getRpmRange3000Fuel(),
                statisticData.getRpmRangeOver3000Fuel(),
        });
        statisticData.setRpmRange500Fuel(intArray[0]);
        statisticData.setRpmRange600Fuel(intArray[1]);
        statisticData.setRpmRange700Fuel(intArray[2]);
        statisticData.setRpmRange800Fuel(intArray[3]);
        statisticData.setRpmRange900Fuel(intArray[4]);
        statisticData.setRpmRange1000Fuel(intArray[5]);
        statisticData.setRpmRange1100Fuel(intArray[6]);
        statisticData.setRpmRange1200Fuel(intArray[7]);
        statisticData.setRpmRange1300Fuel(intArray[8]);
        statisticData.setRpmRange1400Fuel(intArray[9]);
        statisticData.setRpmRange1500Fuel(intArray[10]);
        statisticData.setRpmRange1600Fuel(intArray[11]);
        statisticData.setRpmRange1700Fuel(intArray[12]);
        statisticData.setRpmRange1800Fuel(intArray[13]);
        statisticData.setRpmRange1900Fuel(intArray[14]);
        statisticData.setRpmRange2000Fuel(intArray[15]);
        statisticData.setRpmRange2100Fuel(intArray[16]);
        statisticData.setRpmRange2200Fuel(intArray[17]);
        statisticData.setRpmRange2300Fuel(intArray[18]);
        statisticData.setRpmRange2400Fuel(intArray[19]);
        statisticData.setRpmRange2500Fuel(intArray[20]);
        statisticData.setRpmRange2600Fuel(intArray[21]);
        statisticData.setRpmRange2700Fuel(intArray[22]);
        statisticData.setRpmRange2800Fuel(intArray[23]);
        statisticData.setRpmRange2900Fuel(intArray[24]);
        statisticData.setRpmRange3000Fuel(intArray[25]);
        statisticData.setRpmRangeOver3000Fuel(intArray[26]);
        //转速区间时长
        intArray = fixArrayData(totalDuration, new Integer[]{
                statisticData.getRpmRange500Duration(),
                statisticData.getRpmRange600Duration(),
                statisticData.getRpmRange700Duration(),
                statisticData.getRpmRange800Duration(),
                statisticData.getRpmRange900Duration(),
                statisticData.getRpmRange1000Duration(),
                statisticData.getRpmRange1100Duration(),
                statisticData.getRpmRange1200Duration(),
                statisticData.getRpmRange1300Duration(),
                statisticData.getRpmRange1400Duration(),
                statisticData.getRpmRange1500Duration(),
                statisticData.getRpmRange1600Duration(),
                statisticData.getRpmRange1700Duration(),
                statisticData.getRpmRange1800Duration(),
                statisticData.getRpmRange1900Duration(),
                statisticData.getRpmRange2000Duration(),
                statisticData.getRpmRange2100Duration(),
                statisticData.getRpmRange2200Duration(),
                statisticData.getRpmRange2300Duration(),
                statisticData.getRpmRange2400Duration(),
                statisticData.getRpmRange2500Duration(),
                statisticData.getRpmRange2600Duration(),
                statisticData.getRpmRange2700Duration(),
                statisticData.getRpmRange2800Duration(),
                statisticData.getRpmRange2900Duration(),
                statisticData.getRpmRange3000Duration(),
                statisticData.getRpmRangeOver3000Duration(),
        });
        statisticData.setRpmRange500Duration(intArray[0]);
        statisticData.setRpmRange600Duration(intArray[1]);
        statisticData.setRpmRange700Duration(intArray[2]);
        statisticData.setRpmRange800Duration(intArray[3]);
        statisticData.setRpmRange900Duration(intArray[4]);
        statisticData.setRpmRange1000Duration(intArray[5]);
        statisticData.setRpmRange1100Duration(intArray[6]);
        statisticData.setRpmRange1200Duration(intArray[7]);
        statisticData.setRpmRange1300Duration(intArray[8]);
        statisticData.setRpmRange1400Duration(intArray[9]);
        statisticData.setRpmRange1500Duration(intArray[10]);
        statisticData.setRpmRange1600Duration(intArray[11]);
        statisticData.setRpmRange1700Duration(intArray[12]);
        statisticData.setRpmRange1800Duration(intArray[13]);
        statisticData.setRpmRange1900Duration(intArray[14]);
        statisticData.setRpmRange2000Duration(intArray[15]);
        statisticData.setRpmRange2100Duration(intArray[16]);
        statisticData.setRpmRange2200Duration(intArray[17]);
        statisticData.setRpmRange2300Duration(intArray[18]);
        statisticData.setRpmRange2400Duration(intArray[19]);
        statisticData.setRpmRange2500Duration(intArray[20]);
        statisticData.setRpmRange2600Duration(intArray[21]);
        statisticData.setRpmRange2700Duration(intArray[22]);
        statisticData.setRpmRange2800Duration(intArray[23]);
        statisticData.setRpmRange2900Duration(intArray[24]);
        statisticData.setRpmRange3000Duration(intArray[25]);
        statisticData.setRpmRangeOver3000Duration(intArray[26]);

        //海拔区间
        fixRangeData(totalMileage, totalFuel, totalDuration, statisticData.getAltitudeRanges());

        //小时区间
        fixRangeData(totalMileage, totalFuel, totalDuration, statisticData.getClockRanges());

        //超速90km/h
        statisticData.setSo90Mileage(fixSingleData(totalMileage0,totalMileage, statisticData.getSo90Mileage()));
        statisticData.setSo90Fuel(fixSingleData(totalFuel0,totalFuel, statisticData.getSo90Fuel()));
        statisticData.setSo90Duration(fixSingleData(totalDuration0,totalDuration, statisticData.getSo90Duration()));

        //超速120km/h
        statisticData.setSo120Mileage(fixSingleData(totalMileage0,totalMileage, statisticData.getSo120Mileage()));
        statisticData.setSo120Fuel(fixSingleData(totalFuel0,totalFuel, statisticData.getSo120Fuel()));
        statisticData.setSo120Duration(fixSingleData(totalDuration0,totalDuration, statisticData.getSo120Duration()));

        //超转速
        statisticData.setSrMileage(fixSingleData(totalMileage0,totalMileage, statisticData.getSrMileage()));
        statisticData.setSrFuel(fixSingleData(totalFuel0,totalFuel, statisticData.getSrFuel()));
        statisticData.setSrDuration(fixSingleData(totalDuration0,totalDuration, statisticData.getSrDuration()));

        //低转速（脱档）
        statisticData.setLrogMileage(fixSingleData(totalMileage0,totalMileage, statisticData.getLrogMileage()));
        statisticData.setLrogFuel(fixSingleData(totalFuel0,totalFuel, statisticData.getLrogFuel()));
        statisticData.setLrogDuration(fixSingleData(totalDuration0,totalDuration, statisticData.getLrogDuration()));

        //高速刹车
        statisticData.setHsbMileage(fixSingleData(totalMileage0,totalMileage, statisticData.getHsbMileage()));
        statisticData.setHsbDuration(fixSingleData(totalDuration0,totalDuration, statisticData.getHsbDuration()));

        //普通刹车
        statisticData.setCsbMileage(fixSingleData(totalMileage0,totalMileage, statisticData.getCsbMileage()));
        statisticData.setCsbDuration(fixSingleData(totalDuration0,totalDuration, statisticData.getCsbDuration()));

        //离合时长
        statisticData.setClutchMileage(fixSingleData(totalMileage0,totalMileage, statisticData.getClutchMileage()));
        statisticData.setClutchDuration(fixSingleData(totalDuration0,totalDuration, statisticData.getClutchDuration()));

        //急转弯行驶距离
        statisticData.setSharpTurningMil(fixSingleData(totalMileage0,totalMileage, statisticData.getSharpTurningMil()));

        //疲劳驾驶时长
        statisticData.setFatigueDrivingDuration(fixSingleData(totalDuration0,totalDuration, statisticData.getFatigueDrivingDuration()));

        //经过城市
        Optional.ofNullable(statisticData.getCrossCitiesDetail()).ifPresent(a -> {
            a.forEach(e -> {
                e.setMileage(fixSingleData(totalMileage0, totalMileage, e.getMileage()));
                e.setFuel(fixSingleData(totalFuel0, totalFuel, e.getFuel()));
            });
        });

        //流计算的跨天信息
        Optional.ofNullable(statisticData.getInterCrossDay()).ifPresent(e -> {
            e.setTripLen(fixSingleData(totalMileage0, totalMileage, e.getTripLen()));
            e.setTripOil(fixSingleData(totalFuel0, totalFuel, e.getTripOil()));
            e.setTripTime(fixSingleData(totalDuration0, totalDuration, (int)e.getTripTime()));
        });

        //东风、一汽，急加速
        statisticData.setSharpUpSpeedMileage_DF(fixSingleData(totalMileage0,totalMileage, statisticData.getSharpUpSpeedMileage_DF()));
        statisticData.setSharpUpSpeedFuel_DF(fixSingleData(totalFuel0,totalFuel, statisticData.getSharpUpSpeedFuel_DF()));
        statisticData.setSharpUpSpeedDuration_DF(fixSingleData(totalDuration0,totalDuration, statisticData.getSharpUpSpeedDuration_DF()));

        //东风、一汽，急减速
        statisticData.setSharpDownSpeedMileage_DF(fixSingleData(totalMileage0,totalMileage, statisticData.getSharpDownSpeedMileage_DF()));
        statisticData.setSharpDownSpeedFuel_DF(fixSingleData(totalFuel0,totalFuel, statisticData.getSharpDownSpeedFuel_DF()));
        statisticData.setSharpDownSpeedDuration_DF(fixSingleData(totalDuration0,totalDuration, statisticData.getSharpDownSpeedDuration_DF()));

        //东风、一汽，超长怠速
        statisticData.setLongIdleFuel_DF(fixSingleData(totalFuel0,totalFuel, statisticData.getLongIdleFuel_DF()));
        statisticData.setLongIdleDuration_DF(fixSingleData(totalDuration0,totalDuration, statisticData.getLongIdleDuration_DF()));

        //东风、一汽，冷车运行
        statisticData.setColdRunningMileage_DF(fixSingleData(totalMileage0,totalMileage, statisticData.getColdRunningMileage_DF()));
        statisticData.setColdRunningFuel_DF(fixSingleData(totalFuel0,totalFuel, statisticData.getColdRunningFuel_DF()));
        statisticData.setColdRunningDuration_DF(fixSingleData(totalDuration0,totalDuration, statisticData.getColdRunningDuration_DF()));

        //东风、一汽，夜晚开车
        statisticData.setNightRunningMileage_DF(fixSingleData(totalMileage0,totalMileage, statisticData.getNightRunningMileage_DF()));
        statisticData.setNightRunningFuel_DF(fixSingleData(totalFuel0,totalFuel, statisticData.getNightRunningFuel_DF()));
        statisticData.setNightRunningDuration_DF(fixSingleData(totalDuration0,totalDuration, statisticData.getNightRunningDuration_DF()));

        //东风、一汽，引擎高转速
        statisticData.setHighRotationMileage_DF(fixSingleData(totalMileage0,totalMileage, statisticData.getHighRotationMileage_DF()));
        statisticData.setHighRotationFuel_DF(fixSingleData(totalFuel0,totalFuel, statisticData.getHighRotationFuel_DF()));
        statisticData.setHighRotationDuration_DF(fixSingleData(totalDuration0,totalDuration, statisticData.getHighRotationDuration_DF()));

        //东风、一汽，大油门
        statisticData.setLargeGasMileage_DF(fixSingleData(totalMileage0,totalMileage, statisticData.getLargeGasMileage_DF()));
        statisticData.setLargeGasFuel_DF(fixSingleData(totalFuel0,totalFuel, statisticData.getLargeGasFuel_DF()));
        statisticData.setLargeGasDuration_DF(fixSingleData(totalDuration0,totalDuration, statisticData.getLargeGasDuration_DF()));

        //东风、一汽，全油门
        statisticData.setFullGasMileage_DF(fixSingleData(totalMileage0,totalMileage, statisticData.getFullGasMileage_DF()));
        statisticData.setFullGasFuel_DF(fixSingleData(totalFuel0,totalFuel, statisticData.getFullGasFuel_DF()));
        statisticData.setFullGasDuration_DF(fixSingleData(totalDuration0,totalDuration, statisticData.getFullGasDuration_DF()));

        //东风、一汽，高速行驶
        statisticData.setFastSpeedMileage_DF(fixSingleData(totalMileage0,totalMileage, statisticData.getFastSpeedMileage_DF()));
        statisticData.setFastSpeedFuel_DF(fixSingleData(totalFuel0,totalFuel, statisticData.getFastSpeedFuel_DF()));
        statisticData.setFastSpeedDuration_DF(fixSingleData(totalDuration0,totalDuration, statisticData.getFastSpeedDuration_DF()));

        //东风、一汽，空挡滑行
        statisticData.setNeutralGearCoastMileage_DF(fixSingleData(totalMileage0,totalMileage, statisticData.getNeutralGearCoastMileage_DF()));
        statisticData.setNeutralGearCoastFuel_DF(fixSingleData(totalFuel0,totalFuel, statisticData.getNeutralGearCoastFuel_DF()));
        statisticData.setNeutralGearCoastDuration_DF(fixSingleData(totalDuration0,totalDuration, statisticData.getNeutralGearCoastDuration_DF()));

        //东风、一汽，熄火滑行
        statisticData.setFlameoutCoastMileage_DF(fixSingleData(totalMileage0,totalMileage, statisticData.getFlameoutCoastMileage_DF()));
        statisticData.setFlameoutCoastFuel_DF(fixSingleData(totalFuel0,totalFuel, statisticData.getFlameoutCoastFuel_DF()));
        statisticData.setFlameoutCoastDuration_DF(fixSingleData(totalDuration0,totalDuration, statisticData.getFlameoutCoastDuration_DF()));

        //东风新版，冷车运行
        statisticData.setColdRunningMileage_DFN(fixSingleData(totalMileage0,totalMileage, statisticData.getColdRunningMileage_DFN()));
        statisticData.setColdRunningFuel_DFN(fixSingleData(totalFuel0,totalFuel, statisticData.getColdRunningFuel_DFN()));
        statisticData.setColdRunningDuration_DFN(fixSingleData(totalDuration0,totalDuration, statisticData.getColdRunningDuration_DFN()));

        //东风新版，非经济行驶
        statisticData.setNoEcoMileage_DFN(fixSingleData(totalMileage0,totalMileage, statisticData.getNoEcoMileage_DFN()));
        statisticData.setNoEcoFuel_DFN(fixSingleData(totalFuel0,totalFuel, statisticData.getNoEcoFuel_DFN()));
        statisticData.setNoEcoDuration_DFN(fixSingleData(totalDuration0,totalDuration, statisticData.getNoEcoDuration_DFN()));

        //青汽、一汽，经济车速统计
        statisticData.setEconomicSpeedMileage(fixSingleData(totalMileage0,totalMileage, statisticData.getEconomicSpeedMileage()));
        statisticData.setEconomicSpeedFuel(fixSingleData(totalFuel0,totalFuel, statisticData.getEconomicSpeedFuel()));
        statisticData.setEconomicSpeedDuration(fixSingleData(totalDuration0,totalDuration, statisticData.getEconomicSpeedDuration()));

        //青汽、一汽，经济转速且非下坡
        statisticData.setEcoNoDownMileage(fixSingleData(totalMileage0,totalMileage, statisticData.getEcoNoDownMileage()));
        statisticData.setEcoNoDownFuel(fixSingleData(totalFuel0,totalFuel, statisticData.getEcoNoDownFuel()));
        statisticData.setEcoNoDownDuration(fixSingleData(totalDuration0,totalDuration, statisticData.getEcoNoDownDuration()));

        //青汽、一汽，超经济行驶且非下坡
        statisticData.setEcoOverNoDownMileage(fixSingleData(totalMileage0,totalMileage, statisticData.getEcoOverNoDownMileage()));
        statisticData.setEcoOverNoDownFuel(fixSingleData(totalFuel0,totalFuel, statisticData.getEcoOverNoDownFuel()));
        statisticData.setEcoOverNoDownDuration(fixSingleData(totalDuration0,totalDuration, statisticData.getEcoOverNoDownDuration()));

        //东风，工况时长
        intArray = fixArrayData(totalDuration, new Integer[]{statisticData.getIdleConditionDuration(),statisticData.getLowConditionDuration(),
                statisticData.getAccelerateConditionDuration(),statisticData.getDecelerateConditionDuration(),statisticData.getUniformConditionDuration()});
        statisticData.setIdleConditionDuration(intArray[0]);
        statisticData.setLowConditionDuration(intArray[1]);
        statisticData.setAccelerateConditionDuration(intArray[2]);
        statisticData.setDecelerateConditionDuration(intArray[3]);
        statisticData.setUniformConditionDuration(intArray[4]);

        //东风，工况油耗
        intArray = fixArrayData(totalFuel, new Integer[]{statisticData.getIdleConditionFuel(),statisticData.getLowConditionFuel(),
                statisticData.getAccelerateConditionFuel(),statisticData.getDecelerateConditionFuel(),statisticData.getUniformConditionFuel()});
        statisticData.setIdleConditionFuel(intArray[0]);
        statisticData.setLowConditionFuel(intArray[1]);
        statisticData.setAccelerateConditionFuel(intArray[2]);
        statisticData.setDecelerateConditionFuel(intArray[3]);
        statisticData.setUniformConditionFuel(intArray[4]);
    }

    /**
     * 精准单值
     * @param orgTotal     原始总和
     * @param correctTotal 精准总和
     * @param orgValue       原始值
     * @return 精准值
     */
    private static Integer fixSingleData(int orgTotal, int correctTotal, Integer orgValue) {
        if (orgValue == null ) {
            return null;
        }
        if (orgTotal == correctTotal) {
            return orgValue;
        }
        if (orgTotal <= 0) {
            return 0;
        }

        return (int) ( (1.0 * orgValue / orgTotal) * correctTotal );
    }

    /**
     * 精准数组值
     * @param correctTotal 精准的总数
     * @param orgArray     原始数据的数组
     * @return  精准数组
     */
    private static Integer[] fixArrayData(int correctTotal, Integer[] orgArray) {
        //原始数据累加
        int beforeCorrectSum=0;
        boolean hasValue=false;

        //计算原始数据的累加值
        if(null != orgArray){
            for(Integer item : orgArray){
                if(item != null){
                    if(item >= 0){
                        beforeCorrectSum += item;
                    }
                    hasValue=true;
                }
            }
        }

        if(hasValue && beforeCorrectSum>=0){
            //精准后的数据累加
            int afterCorrect = 0;

            //精准后的数据数组
            Integer[] ints = new Integer[orgArray.length];

            for(int i=0; i<orgArray.length; i++){
                Integer item = orgArray[i];
                int in = null!=item ? item : 0;
                if(beforeCorrectSum >0 ) {
                    //原始数据占总原始数据和的比例 * 精准的总和
                    ints[i] = BigDecimal.valueOf(in).divide(BigDecimal.valueOf(beforeCorrectSum), 6, BigDecimal.ROUND_DOWN)
                            .multiply(BigDecimal.valueOf(correctTotal)).setScale(0, BigDecimal.ROUND_DOWN).intValue();
                }else{
                    ints[i]=0;
                }
                afterCorrect += ints[i];
            }

            //找出最大值的index
            int maxValue = ints[0];
            int lastFixtIdx=0;
            for(int i=1; i<ints.length; i++){
                if(maxValue < ints[i]){
                    maxValue = ints[i];
                    lastFixtIdx = i;
                }
            }

            //保证总数完全能对上
            ints[lastFixtIdx] = ints[lastFixtIdx] + (correctTotal - afterCorrect);
            if(ints[lastFixtIdx] <0 ){
                ints[lastFixtIdx] = 0;
            }

            return ints;
        }else{
            return orgArray;
        }
    }

    /**
     * 精准区间值
     * @param totalMileage      精准里程
     * @param totalFuel         精准油耗
     * @param totalDuration     精准时长
     * @param altitudeRanges    待精准值
     */
    private static void fixRangeData(int totalMileage, int totalFuel, int totalDuration, Map<Integer, InterRangeData> altitudeRanges) {
        if (altitudeRanges != null && altitudeRanges.size() > 0) {
            Integer[] fuels = new Integer[altitudeRanges.size()];
            Integer[] mileages = new Integer[altitudeRanges.size()];
            Integer[] durations = new Integer[altitudeRanges.size()];
            Integer[] indexes = new Integer[altitudeRanges.size()];

            int i = 0;
            for (Map.Entry<Integer, InterRangeData> entry : altitudeRanges.entrySet()) {
                indexes[i] = entry.getKey();
                InterRangeData data = entry.getValue();
                fuels[i] = data.getFuel();
                mileages[i] = data.getMileage();
                durations[i] = data.getTime();
                i++;
            }

            Integer[] intFuels = fixArrayData(totalFuel, fuels);
            Integer[] intMileages = fixArrayData(totalMileage,mileages);
            Integer[] intDurations = fixArrayData(totalDuration, durations);
            i=0;
            for(int idx : indexes){
                InterRangeData data=altitudeRanges.get(idx);
                data.setFuel(intFuels[i]);
                data.setMileage(intMileages[i]);
                data.setTime(intDurations[i]);
                i++;
            }
        }
    }

}
